﻿<UserControl x:Class="KegManager.TapControl"
             x:Name="tapControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:my="clr-namespace:KegManager"
             mc:Ignorable="d" 
             d:DesignHeight="500" d:DesignWidth="400">
    <UserControl.Resources>
        <my:PathLabelConverter x:Key="PathLabelConverter" />
    </UserControl.Resources>
    <DockPanel Width="350" Height="369">
        <DockPanel.Style>
            <Style TargetType="DockPanel">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding}" Value="{x:Null}">
                        <Setter Property="Opacity" Value=".5" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </DockPanel.Style>
        <my:KegControl Grid.Column="0" Grid.Row="1" Value="{Binding Path=Keg.CurrentVolume, ElementName=tapControl}" Color="{Binding Path=Keg.Beer.Color, ElementName=tapControl}" VerticalAlignment="Top" Height="150" Margin="0,35,0,0" DockPanel.Dock="{Binding ElementName=tapControl, Path=KegDock}"/>
        <Grid Width="300">
            <Grid.RowDefinitions>
                <RowDefinition Height="35" />
                <RowDefinition Height="300" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="0" FontSize="24" TextAlignment="Center" FontWeight="Bold" Text="{Binding Path=Keg.Beer.Name, ElementName=tapControl, TargetNullValue={x:Null}, FallbackValue=No Keg on Tap}"></TextBlock>
            <Image  Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="1"  Margin="0,0,0,0" Height="300" Width="300"
                   Source="{Binding Path=Keg.Beer.Label, ElementName=tapControl, Converter={StaticResource PathLabelConverter}, FallbackValue=/KegManager;component/resources/nokeg.png}">
                <!--<Image.Style>
                    <Style TargetType="Image">
                        <Style.Triggers>
                            <DataTrigger Value="{x:Null}" Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=my:TapControl, AncestorLevel=1}, Path=Keg}">
                                <Setter Property="Source" Value="/KegManager;component/resources/nokeg.png" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Image.Style>-->
            </Image>
            <TextBlock Grid.Column="0" Grid.Row="2" FontSize="18" HorizontalAlignment="Center">OG: <TextBlock  FontSize="18" TextAlignment="Center" Text="{Binding Path=Keg.Beer.Gravity, ElementName=tapControl}"></TextBlock></TextBlock>
            <TextBlock Grid.Column="1" Grid.Row="2" FontSize="18" HorizontalAlignment="Center">ABV: <TextBlock  FontSize="18" TextAlignment="Center" Text="{Binding Path=Keg.Beer.Alcohol, ElementName=tapControl}"></TextBlock>%</TextBlock>
            <TextBlock Grid.Column="2" Grid.Row="2" FontSize="18" HorizontalAlignment="Center">IBU: <TextBlock  FontSize="18" TextAlignment="Center" Text="{Binding Path=Keg.Beer.Bitterness, ElementName=tapControl}"></TextBlock></TextBlock>
        </Grid>
    </DockPanel>
</UserControl>
